package edu.chinasoft.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.annotation.WebServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import edu.chinasoft.domain.Dept;
import edu.chinasoft.service.DeptService;

/**
 *
 * @author mhao
 * @date 2020年2月12日:下午3:56:48
 * @version V1.0
 * @Description: 
*/
@WebServlet(name = "myGetDeptForAddUserServlet", value = "/servlet/getdeptforadduserservlet")
public class GetDeptForAddUserServlet extends HttpServlet {
	private static Logger logger = LoggerFactory.getLogger(GetDeptForAddUserServlet.class);
	private DeptService deptService;
	/**
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		logger.info(" GetDeptForAddUserServlet >doGet start.......");
		WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
		DeptService deptServiceImp = wac.getBean("deptService", DeptService.class);
		this.deptService=deptServiceImp;
		List<Dept> deptList = deptService.selectDept();
		HttpSession session = request.getSession();
		session.setAttribute("deptInfo", deptList);
		response.sendRedirect(request.getContextPath()+"/addUser.jsp");
		logger.info(" GetDeptForAddUserServlet >doGet end.......");
	}

	/**
	 *
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		logger.info(" GetDeptForAddUserServlet >doPost start.......");

		logger.info(" GetDeptForAddUserServlet >doPost end.......");
	}

}
